package cn.itsource.ymcc.feignclient.fallback;

import cn.itsource.domain.CourseDoc;
import cn.itsource.ymcc.feignclient.EsFeignClient;
import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class EsFeignclientFallbackFactory implements FallbackFactory<EsFeignClient> {
    @Override
    public EsFeignClient create(Throwable throwable) {
        return new EsFeignClient() {
            @Override
            public JsonResult batchSave(List<CourseDoc> docList) {
                return JsonResult.error(throwable.getMessage());
            }
        };
    }
}
